import com.rfid.service.IRfidCategoryService;
import com.rfid.service.impl.RfidCategoryServiceImpl;
import com.rfid.tool.ComX;
import com.ruoyi.RuoYiApplication;
import gnu.io.NoSuchPortException;
import gnu.io.PortInUseException;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.Enumeration;

/**
 * 该类实现3个功能
 * 1.列举出本地所有的串口;
 * 2.打开所有串口(但是未向串口中写数据);
 * 3.关闭打开的串口。
 */
@SpringBootTest(classes = RuoYiApplication.class)
public class OpenerAndCloser {
//    @Test
//    public void getAllPort(){
//        //1.获取本地所有的端口并输出其名称：
//        //1.1.用于标识端口的变量
//        CommPortIdentifier portIdentifier = null;
//
//        //1.2.记录所有端口的变量
//        Enumeration<?> allPorts = CommPortIdentifier.getPortIdentifiers();
//
//        //1.3.输出每一个端口
//        while(allPorts.hasMoreElements()){
//            portIdentifier = (CommPortIdentifier) allPorts.nextElement();
//            System.out.println("串口：" + portIdentifier.getName());
//        }
//    }
//
    @Test
    public  void openPort1() throws NoSuchPortException, PortInUseException {
        String str="10086";
        ComX com1Writer=new ComX();
        //com1Writer.Writer(str);
    }
    @Test
    public  void openRead() throws NoSuchPortException, PortInUseException {
        ComX com1Writer=new ComX();
        com1Writer.Read();
    }
//

    @Autowired
    IRfidCategoryService iRfidCategoryService;
    @Test
    public void test1(){
        System.out.println(iRfidCategoryService.buildCategoryTreeByList());
    }
}
